package
{
    import starling.display.Button;
    import starling.display.Sprite;
    import starling.events.Event;
    import starling.textures.Texture;

    import brickred.core.Director;

    public class SceneNaviBar extends Sprite
    {
        private var up_state_:Texture;
        private var down_state_:Texture;
        private var buttons_:Array;
        private var scene1_:Scene1;
        private var scene2_:Scene2;
        private var scene3_:Scene3;

        public function SceneNaviBar()
        {
            up_state_ = Texture.fromColor(100, 20, 0xffffffff);
            down_state_ = Texture.fromColor(100, 20, 0xffaaaaaa);
            buttons_ = new Array();

            var button:Button;

            button = new Button(up_state_, "scene1", down_state_);
            button.addEventListener(Event.TRIGGERED, onButtonScene1);
            buttons_.push(button);
            button = new Button(up_state_, "scene2", down_state_);
            button.addEventListener(Event.TRIGGERED, onButtonScene2);
            buttons_.push(button);
            button = new Button(up_state_, "scene3", down_state_);
            button.addEventListener(Event.TRIGGERED, onButtonScene3);
            buttons_.push(button);

            for (var i:int = 0; i < buttons_.length; ++i) {
                buttons_[i].x = 0;
                buttons_[i].y = 100 + i * 22;
                addChild(buttons_[i]);
            }
        }

        public function onButtonScene1(event:*):void
        {
            if (null == scene1_) {
                scene1_ = new Scene1();
            }
            Director.getInstance().runScene(scene1_);
        }

        public function onButtonScene2(event:*):void
        {
            if (null == scene2_) {
                scene2_ = new Scene2();
            }
            Director.getInstance().runScene(scene2_);
        }

        public function onButtonScene3(event:*):void
        {
            if (null == scene3_) {
                scene3_ = new Scene3();
            }
            Director.getInstance().runScene(scene3_);
        }
    }
}

